import request from "@/utils/request";
import axios from "axios";
//获取上传凭证/并把文件先保存于数据库，如果上传失败，请根据uuid删掉当前记录--------------------------------------------
export function getUploadKey(data) {
  return request({
    url: "/web/v1/upload/centerOptionFile/getUploadKey",
    method: "post",
    data
  });
}
//条件查询文件--------------------------------------------
export function getFileList(params) {
  return request({
    url: "/web/v1/upload/centerOptionFile/getFileList",
    method: "get",
    params
  });
}
//条件删除文件--------------------------------------------
export function delFile(params) {
  return request({
    url: "/web/v1/upload/centerOptionFile/delFile",
    method: "delete",
    params
  });
}

//上传阿里云--------------------------------------------
export const ossUpload = (data, url, uploadCallback, index) => {
  return axios({
    method: "post",
    url: `${url}`,
    withCredentials: false,
    data: data,
    onUploadProgress: progressEvent => {
      if (uploadCallback) {
        uploadCallback(progressEvent, index);
      }
    }
  });
};
